package com.appbee.core.client.cell;

import com.google.gwt.cell.client.ButtonCell;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;

/**
 * Button cell with class attribute on button tag.
 * 
 * @author jakobmarrunarsson
 * 
 */
public class StyleButtonCell extends ButtonCell
{
	private final String style;

	public StyleButtonCell(String style)
	{
		super();
		this.style = style;
	}

	@Override
	public void render(com.google.gwt.cell.client.Cell.Context context,
			SafeHtml data, SafeHtmlBuilder sb)
	{
		sb.appendHtmlConstant("<button type=\"button\" class=\"" + style
				+ "\" tabindex=\"-1\">");
	    if (data != null) {
	      sb.append(data);
	    }
	    sb.appendHtmlConstant("</button>");
	}

}
